import request from '@/utils/axios';
import TalkQuery from '@/api/module/talk';

interface IResponseType<P = {}> {
    code?: number;
    msg: string;
    data: P;
}

// @ts-ignore
export const page = (talk : TalkQuery)=>{
    return request<IResponseType>({
        url: '/talk/page',
        method: 'post',
        data: talk
    })
}
export const add = (formData: FormData)=>{
    return request<IResponseType>({
        url: '/talk/add',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'application/json' // 设置默认的请求头
        }
    })
}
export const getDetail = (id: number)=>{
    return request<IResponseType>({
        url: '/talk/getTalkDetail',
        method: 'get',
        params: {id : id},
    })
}
export const addComment = (formData: FormData)=>{
    return request<IResponseType>({
        url: '/talk/addComment',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'application/json' // 设置默认的请求头
        }
    })
}
export const tree = (id : number)=>{
    return request<IResponseType>({
        url: '/talk/tree',
        method: 'get',
        params: {talkId : id},
    })
}
// @ts-ignore
export const myTalk = (talk : TalkQuery)=>{
    return request<IResponseType>({
        url: '/talk/myTalkPage',
        method: 'post',
        data: talk
    })
}
// @ts-ignore
export const myComment = (talk : TalkQuery)=>{
    return request<IResponseType>({
        url: '/talk/myCommentPage',
        method: 'post',
        data: talk
    })
}
export default { page,add,getDetail,addComment,tree,myTalk,myComment };